package utils.output.html;

import java.util.ArrayList;

public class Table {

	protected Integer id;
	protected String[] theader;
	protected ArrayList<String[]> content;
	
	public Table(Integer id){
		this.id = id;
	}
	
	public void set_theader(String[] header){
		this.theader = header;
	}
	
	public void set_content(ArrayList<String[]> content){
		this.content = content;
	}
	
	public String gettable(){
		String result = "<table id=\""+this.id+"\">"+System.lineSeparator()+"<tbody>"+System.lineSeparator();
		result += "<tr>"+System.lineSeparator();
		for(int i = 0;i<this.theader.length;i++){
			result += "<th>"+this.theader[i]+"</th>"+System.lineSeparator();
		}
		result += "</tr>"+System.lineSeparator();
		for(int i =0; i<this.content.size();i++){
			result += "<tr>"+System.lineSeparator();
			for(int j =0; j<this.content.get(i).length;j++){
				result += "<td>"+this.content.get(i)[j]+"</td>"+System.lineSeparator();
			}
			result += "</tr>"+System.lineSeparator();
		}
		result += "</tbody>"+System.lineSeparator();
		result += "</table>"+System.lineSeparator();
		
		return result;
	}
}
